void on_updata_cfg_btn_clicked();
#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QTimer>
#include "modbushost.h"
#include <QThread>
QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();
    bool mosbus_is_alive;
private:
    Ui::MainWindow *ui;
    ModbusHost *modbus_host;
    QTimer * cfg_show_timer;
    QTimer * env_show_timer;
    void close_all_time();
    /* 与线程相关*/
    //send to thread
    void connect_modbus_tothread();
    void searchPort_tothread();
    void get_cfg_timing_tothread();
    void get_env_timing_tothread();

    QThread * workthread;
signals:
    void request_write_hold_reg(qint16 regaddr,qint16 data);
public slots:
    /* 与线程相关*/
    //recv  from thread
    void recv_Port_fromthread(QStringList portList);
    void recv_cfg_fromthread(QVector<QString> cfg_string);
    void recv_env_fromthread(QVector<QString> cfg_string);

    void recv_modbus_err_code_handle(ret_code_t code);
    void onTabChanged(int index);
private slots:
    void on_simulate_temp_btn_clicked();
    void on_updata_cfg_btn_clicked();
};


#endif // MAINWINDOW_H
